<?php

namespace app\api\model\vipcard;

use app\common\model\card\Card as CardModel;

/**
 * 储值卡模型
 * Class Plan
 * @package app\api\model\recharge
 */
class Card extends CardModel
{

    /**
     * 隐藏字段
     * @var array
     */
    protected $hidden = [
        'wxapp_id',
        'create_time',
    ];

    /**
     * 获取器：储值卡面值
     * @param $value
     * @return int
     */
    public function getCardMoneyAttr($value)
    {
        return ($value == $intValue = (int)$value) ? $intValue : $value;
    }

    /**
     * 获取器：储值卡面实付金额
     * @param $value
     * @return int
     */
    public function getCardRealMoneyAttr($value)
    {
        return ($value == $intValue = (int)$value) ? $intValue : $value;
    }


    /**
     * 获取可用的充值套餐列表
     * @return false|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getList()
    {
        $list = $this->with(['image'])
            ->where(['is_delete'=>0])
            ->select();
        return $list;
    }



}